/* tracking of a simulated bug
 * for biomimetic modelling

 */


#include "globals.h"
#include "LynxWinFunc.h"
#include "Lynx6.h"

using namespace std;

LynxWinFunc* app;
int window1ID, window2ID;

void display(void) {
	app->DisplayCallback();
}

void reshape(int w, int h) {
	app->ResizeCallback(w,h);
}

void idle(void) {
	app->IdleCallback();
}

void mouse(int button, int state, int x, int y) {
	app->MouseCallback(button, state, x, y);
}

void keyboard(unsigned char key, int x, int y) {
	app->KeyboardCallback(key, x, y);
}

int main( int argc, char* argv[] )
{
	
	cout<<"Bugtracker... \n";
	cout<<"\n Your System Properties: \n";



	glutInit( &argc, argv );
	glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB );
	int w = 640;
	int h = 480;
	// window 1
	glutInitWindowSize(w, h);
	glutInitWindowPosition(1,1);
	window1ID = glutCreateWindow("window one");
	glutDisplayFunc( display );
	glutReshapeFunc(reshape);
	glutKeyboardFunc(keyboard);
	//glutMouseFunc(mouse);

	// window2
	int mult_win = 1;
	if( mult_win > 1 ) {
		glutInitWindowSize(w, h);
		glutInitWindowPosition(w+10,1);
		window2ID = glutCreateWindow("window two");
		glutDisplayFunc( display );
		glutReshapeFunc(reshape);
		glutKeyboardFunc(keyboard);
		glutMouseFunc(mouse);
	}

	//// window3
	//if( mult_win > 1 ) {
	//	glutInitWindowSize(w, h);
	//	glutInitWindowPosition(1,h+60);
	//	window2ID = glutCreateWindow("window three");
	//	glutDisplayFunc( display );
	//	glutReshapeFunc(reshape);
	//	glutKeyboardFunc(keyboard);
	//	glutMouseFunc(mouse);
	//}
	//// window4
	//if( mult_win > 1 ) {
	//	glutInitWindowSize(w, h);
	//	glutInitWindowPosition(w+10,h+60);
	//	window2ID = glutCreateWindow("window four");
	//	glutDisplayFunc( display );
	//	glutReshapeFunc(reshape);
	//	glutKeyboardFunc(keyboard);
	//	glutMouseFunc(mouse);
	//}


	// the idle func is shared
	glutIdleFunc(idle);

 	cout<<"OpenGL version: "<<glGetString( GL_VERSION )<<"\n";
	cout<<"Vendor: "<<glGetString( GL_VENDOR )<<"\n";
	cout<<"Renderer: "<<glGetString( GL_RENDERER )<<"\n";
	cout<<"done glutInit...\n";

	app = new LynxWinFunc(w, h, mult_win);
	glutMainLoop();

	return 0;


}